-- string.find
s = "hello world"
i, j = string.find(s, "hello") 	-- 1 5 (start and end)
string.find("a [word]", "[") 		-- error because "[" is a part of pattern
string.find("a [word]", "[", 1, true)
																-- the third parameter is the start index
																-- the fourth parameter means ignore pattern

-- string.match
date = "Today is 17/7/1990"
d = string.match(date, "%d+/%d+/%d+")
print(d) 	-- 17/7/1990

-- string.gsub
s = string.gsub("lua is cute", "cute", "great")
print(s) 	-- lua is great
s = string.gsub("all lii", "l", "x")
print(s) 	-- axx xii
s = string.gsub("lua is great", "sol", "sun")
print(s) 	-- lua is great 	--> nothing mathched
s = string.gsub("all lii", "l", "x", 2) 	-- 1 means replace 2 times
print(s) 	-- axx lii

-- string.gmatch 	--> return a function
s = "some string"
words = {}
for w in string.gmatch(s, "%a+") do
	words[#words + 1] = w
end

-- character class
-- .		--> all characters
-- %a 	--> alphabet character
-- %c 	--> control character
-- %d 	--> number
-- %g 	--> printable character except space
-- %l 	--> lower case alphabet character
-- %u 	--> upper case alphabet character
-- %p 	--> punctuation mark character
-- %s 	--> space character
-- %w 	--> alphabet and number character
-- %x 	--> hexadecimal number
-- the captialization of these classes indicates complements

-- magic character
-- ( ) . % + - * ? [ ] ^ $
